#include<bits/stdc++.h>
using namespace std;
void work()
{
	int n,m,l,v;
	cin>>n>>m>>l>>v;
	int dt[3005],vt[3005],at[3005];
	for(int i=1;i<=n;i++)
	{
		cin>>dt[i]>>vt[i]>>at[i];
	}
	int p[3005];
	bool vi[1000005]={0};
	for(int i=1;i<=m;i++)
	{
		cin>>p[i];
		vi[p[i]]=1;
	}
	int qzh[1000005];
	if(vi[0])
	{
		qzh[0]=1;
	}
	else
	{
		qzh[0]=0;
	}
	for(int i=1;i<=l;i++)
	{
		if(vi[i])
		{
			qzh[i]=qzh[i-1]+1;
		}
		else
		{
			qzh[i]=qzh[i-1];
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(at[i]>0)
		{
			double vttt=(v*v-vt[i]*vt[i])*0.5/at[i];
			int vtt=vttt;
			vtt+=dt[i];
			if(vttt-vtt>0.000001)
			{
				vtt++;
			}
			if(vtt>l)
			{
				continue;
			}
			else if(qzh[l]-qzh[vtt]>0)
			{
				cnt++;
			}
		}
		else if(at[i]<0)
		{
			
		}
	}
	cout<<cnt<<endl;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	cin>>t;
	for(int tttt=1;tttt<=t;tttt++)
	{
		work();
	}
	return 0;
}
